<?php


namespace App\Http\Controllers\Saas;


use App\Http\Controllers\Controller;
use App\Model\Article;
use App\Utils\Result;
use Illuminate\Http\Request;

class ArticleController extends Controller
{
    public function index(Request $request)
    {
        $query = Article::query();

        $data = $query->get(['id', 'title']);

        return Result::success($data);
    }

    public function detail($id)
    {
        $res = Article::query()->find($id);

        return Result::success($res);
    }

    public function update(Request $request, $id)
    {
        $data = $request->only([
            'title',
            'content',
        ]);
        $qa = Article::query()->find($id);
        $qa->fill($data);
        $qa->save();

        return Result::success();
    }
}
